package com.beidu.lottery.call.constant;

import com.beidu.lottery.call.errorcode.CommonCode;
import com.beidu.lottery.call.exception.ServiceException;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 奖品类型枚举
 *
 * @author tennyson
 */
@Getter
@AllArgsConstructor
public enum PrizeTypeEnum {

    PHYSICAL(0, "实体奖品"),
    VIRTUAL(1, "虚拟奖品"),
    INTEGRAL(2, "积分奖品");

    private final Integer code;

    private final String msg;

    /**
     * 初始化订单状态
     *
     * @param type 奖品类型
     * @author 北渡
     */
    public static Integer initOrderStatus(Integer type) {
        // 实体奖品
        if (type.equals(PHYSICAL.code))
            return OrderStatusEnum.UNISSUED.getCode();
        // 虚拟奖品
        if (type.equals(VIRTUAL.code))
            return OrderStatusEnum.TO_BE_DISTRIBUTED.getCode();
        // 积分奖品
        if (type.equals(INTEGRAL.code))
            return OrderStatusEnum.ISSUED.getCode();
        // 未知
        throw new ServiceException(CommonCode.ACTIVITY_NOT_EXIST.getMsg());
    }

}
